<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <script src="js/vue.js"></script>
    <script src="element-ui/lib/index.js"></script>
    <link rel="stylesheet" href="element-ui/lib/theme-chalk/index.css">

    <style>
        .el-table .warning-row {
            background: oldlace;
        }

        .el-table .success-row {
            background: #f0f9eb;
        }
    </style>
</head>
<body>

<div id="add">

<!--查询信息-->
    <el-form :inline="true" :model="brand" class="demo-form-inline">
        <el-form-item label="当前状态">
            <el-select v-model="brand.status" placeholder="当前状态">
                <el-option label="禁用" value="0"></el-option>
                <el-option label="启用" value="1"></el-option>
            </el-select>
        </el-form-item>

        <el-form-item label="企业名称">
            <el-input v-model="brand.brand" placeholder="企业名称"></el-input>
        </el-form-item>

        <el-form-item label="品牌名称">
            <el-input v-model="brand.company" placeholder="品牌名称"></el-input>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="onSubmit">查询</el-button>
        </el-form-item>
    </el-form>


<!--    按钮-->
    <el-row>
        <el-button type="danger" plain>批量删除</el-button>
        <el-button type="primary"  @click="dialogVisible = true" plain>新增</el-button>
    </el-row>

<!--    新增按钮信息-->
    <el-dialog
            title="编辑品牌"
            :visible.sync="dialogVisible"
            width="30%">
        <el-form ref="form" :model="addbrand" label-width="80px">
            <el-form-item label="品牌名称">
                <el-input v-model="addbrand.brandName"></el-input>
            </el-form-item>
            <el-form-item label="企业名称">
                <el-input v-model="addbrand.companyName"></el-input>
            </el-form-item>
            <el-form-item label="排序">
                <el-input v-model="addbrand.ordered"></el-input>
            </el-form-item>

            <el-form-item label="备注">
                <el-input type="textarea" v-model="addbrand.description"></el-input>
            </el-form-item>

            <el-form-item label="状态">
                <el-switch v-model="addbrand.status"
                           active-value="1"
                           inactive-value="0"></el-switch>
            </el-form-item>

            <el-form-item>
                <el-button type="primary" @click="onSubmit2">提交</el-button>
                <el-button @click="dialogVisible = false">取消</el-button>
            </el-form-item>



        </el-form>

    </el-dialog>



<!--表单信息-->
<template>
    <el-table
            :data="tableData"
            style="width: 100%"
            :row-class-name="tableRowClassName"
            align="center"
            @selection-change="handleSelectionChange"
    >

        <el-table-column
                type="selection"
                width="55">
        </el-table-column>

        <el-table-column
                type="index"
                width="150">
        </el-table-column>


        <el-table-column
                prop="brandName"
                label="品牌">
        </el-table-column>
        <el-table-column
                prop="companyName"
                label="企业名称">
        </el-table-column>
        <el-table-column
                prop="ordered"
                label="排序">
        </el-table-column>
        <el-table-column
                prop="status"
                label="当前状态"
                width="180">
        </el-table-column>
    </el-table>
</template>


    <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage4"
            :page-sizes="[5, 20, 40, 60]"
            :page-size="100"
            layout="total, sizes, prev, pager, next, jumper"
            :total="400">
    </el-pagination>
</div>

<script>
    new Vue({
        el:"#add",
        data() {
            return {
                tableData: [{
                    brandName: '华为',
                    companyName: '华为科技有限公司',
                    ordered: '1000',
                    status:'20'
                }, {
                    brandName: '华为',
                    companyName: '华为科技有限公司',
                    ordered: '1000',
                    status:'20'
                }, {
                    brandName: '华为',
                    companyName: '华为科技有限公司',
                    ordered: '1000',
                    status:'20'
                }, {
                    brandName: '华为',
                    companyName: '华为科技有限公司',
                    ordered: '1000',
                    status:'20'
                }],
                brand: {
                    status: '',
                    brand: '',
                    company:''
                },
                dialogVisible: false,
                addbrand: {
                    id:'',
                    brandName: '',
                    companyName: '',
                    ordered: '',
                    description: '',
                    status: ''
                },
                currentPage4: 4
            }
        },
        methods: {
            tableRowClassName({row, rowIndex}) {
                if (rowIndex === 1) {
                    return 'warning-row';
                } else if (rowIndex === 3) {
                    return 'success-row';
                }
                return '';
            },
            onSubmit() {
                console.log(this.brand);
            },
            handleSelectionChange(val) {
                this.multipleSelection = val;
            },
            onSubmit2(){
                console.log(this.addbrand);
            },
            handleSizeChange(val) {
                console.log(`每页 ${val} 条`);
            },
            handleCurrentChange(val) {
                console.log(`当前页: ${val}`);
            }
        }

    })
</script>


</body>
</html>